export default {
    namespaced: true,
    state: {
        goodslist: [
            {
                id: '1',
                name: '【联通5G套餐】魅族17',
                imgsrc: 'https://openfile.meizu.com/group1/M00/08/10/Cgbj0F8jhKSAcY_ZAAx8PRn7kUE396.png@240x240.jpg',
                info: ['全网通公开版', 'AG原野绿', '8+256G'],
                price: 3999,
                num: 1,
                maxNum: 4,
            },
            {
                id: '2',
                name: '【暖冬套餐】魅族17',
                imgsrc: 'https://openfile.meizu.com/group1/M00/07/C4/Cgbj0F6zwMuANEeWAAw6yQFAJXM097.png@240x240.jpg',
                info: ['全网通公开版', 'AG梦幻独角兽', '8+128G'],
                price: 4399,
                num: 1,
                maxNum: 2,
            },
            {
                id: '3',
                name: '魅族 HD60 降噪耳机',
                imgsrc: 'https://openfile.meizu.com/group1/M00/07/E0/Cgbj0V6z8VSAV6kEAAlCc-omYno614.png@240x240.jpg',
                info: ['雾银黑'],
                price: 1099,
                num: 1,
                maxNum: 6,
            },
            {
                id: '4',
                name: '魅族超充 GaN 三口充电器',
                imgsrc: 'https://openfile.meizu.com/group1/M00/07/D7/Cgbj0F67s3yAYmI6AAIrMK1gFWU758.png@240x240.jpg',
                info: ['白色'],
                price: 199,
                num: 1,
                maxNum: 10,
            },
        ],
    },
    getters: {},
    mutations: {
        delete(state, payload) {
            state.goodslist.splice(payload, 1);
        },
        add(state, payload) {
            console.log(payload);
            if (state.goodslist[payload.index1].num <= 1 && payload.val1 == -1) return;
            if (
                state.goodslist[payload.index1].num == state.goodslist[payload.index1].maxNum &&
                payload.val1 == 1
            )
                return;
            state.goodslist[payload.index1].num += payload.val1;
            console.log(state.goodslist.num);
        },
    },
    actions: {},
};
